# Contributor: Alan Lacerda <alacerda@alpinelinux.org>
# Maintainer: Alan Lacerda <alacerda@alpinelinux.org>
pkgname=setup-box
pkgver=1.0.1
pkgrel=0
pkgdesc="A tool to setup a variety of Alpine Linux Environments"
url="https://git.alpinelinux.org/cgit/alacerda/setup-box/"
arch="noarch"
license="MIT"
depends="jq"
depends_dev=""
makedepends="$depends_dev"
install=""
subpackages="$pkgname-doc"
source="https://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.bz2"

_builddir="$srcdir/$pkgname-$pkgver"
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

doc () {
	mkdir -p "$subpkgdir"/usr/share/man/man1 || return 1
	mv "$_builddir"/usr/share/man/setup-box.1.gz "$subpkgdir"/usr/share/man/man1/ || return 1
}

build() {
	cd "$_builddir"
}

package() {
	cd "$_builddir"
	mkdir -p "$pkgdir"/etc/setup-box/json
	mkdir "$pkgdir"/sbin
	install -m 755 setup-box "$pkgdir"/sbin/$pkgname
	cp json/* "$pkgdir"/etc/setup-box/json
	sed -e 's:@CONFIG_DIR@:/etc/setup-box:g' -i "$pkgdir"/sbin/$pkgname
	sed -e 's:@JSON_DIR@:/etc/setup-box/json:g' -i "$pkgdir"/sbin/$pkgname
	sed -e 's:@VERSION@:v$pkgver:g' -i "$pkgdir"/sbin/$pkgname
}

sha512sums="22891037b4a0ed8a60103959e21b2d99e4bdf0a518419141623373b6a7a1c0160c8bd761ca81637bef069078849d06952817eaef83fd5c426ae9693329c29e48  setup-box-1.0.1.tar.bz2"
